﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
public partial class Main_Inventory_PurchaseOrderPagePermission : System.Web.UI.Page
{
    Datautility DU = new Datautility();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["userid"] == null)
        {
            Response.Redirect("~/SessionExpired.aspx");
        }
        if (!IsPostBack)
        {
            Permission();
        }
    }
    protected void Permission()
    {
        string UserID = Session["userid"].ToString();
        string UserIDsql = "Select * From Group_Permission where GROUP_ID in (select GROUPID from LOGIN where Userid="+ UserID+")" ;
        DataTable DTPermission = DU.getdata(UserIDsql);
        if (DTPermission.Rows.Count > 0)
        {
            for (int i = 0; i < DTPermission.Rows.Count; i++)
            {
                if (DTPermission.Rows[i]["MODULE_ID"].ToString() == "448")//For Finance Purchase Order.
                {
                    imgPOFinanaceApproval.Style["display"] = "block";
                    lbtnPOFinanceApproval.Style["display"] = "block";
                    //lbtnPOFinanceView.Style["display"] = "block";
                }
                if (DTPermission.Rows[i]["MODULE_ID"].ToString() == "417")//For Purchase Order.
                {
                    ImgPurchaseOrder.Style["display"] = "block";
                    //lbtnPurchaseOrder.Style["display"] = "block";
                    //lbtnPurchaseView.Style["display"] = "block";
                }
                if (DTPermission.Rows[i]["MODULE_ID"].ToString() == "1028")//For Manager Purchase Order.
                {
                    imgPoManagerApproval.Style["display"] = "block";
                    lbtnPOManagerApproval.Style["display"] = "block";
                    //lbtnPOManagerView.Style["display"] = "block";
                }
                if (DTPermission.Rows[i]["MODULE_ID"].ToString() == "1026")//For Admin Purchase Order.
                {
                    imgPoAdminApproval.Style["display"] = "block";
                    lbtnPOAdminApproval.Style["display"] = "block";
                    //lbtnPOAdminView.Style["display"] = "block";
                }
            }
        }
        else
        {
            imgPOFinanaceApproval.Style["display"] = "block";
            lbtnPOFinanceApproval.Style["display"] = "block";
            //lbtnPOFinanceView.Style["display"] = "block";

            ImgPurchaseOrder.Style["display"] = "block";
            //lbtnPurchaseOrder.Style["display"] = "block";
            //lbtnPurchaseView.Style["display"] = "block";

            imgPoManagerApproval.Style["display"] = "block";
            lbtnPOManagerApproval.Style["display"] = "block";
            //lbtnPOManagerView.Style["display"] = "block";

            imgPoAdminApproval.Style["display"] = "block";
            lbtnPOAdminApproval.Style["display"] = "block";
            //lbtnPOAdminView.Style["display"] = "block";
        }
    }
}